import { PrimaryGeneratedColumn, Column, ManyToMany } from 'typeorm';
import { EntityModel } from '@midwayjs/orm';
import { SysRole } from './role';

@EntityModel('sys_menu')
export class SysMenu {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string;

  @Column({ nullable: true })
  router: string;

  @Column()
  icon: string;

  @Column({ nullable: true })
  perms: string;

  @Column({ type: 'tinyint', default: 0 })
  type: number;

  @Column({ name: 'order_num', type: 'int', default: 0, nullable: true })
  orderNum: number;

  @Column({ name: 'view_path', nullable: true })
  viewPath: string;

  @Column({ type: 'bool', nullable: true, default: true })
  keepalive: boolean;
  @Column({ type: 'bool', default: true, nullable: true })
  isShow: boolean;

  @ManyToMany(() => SysRole, sysRole => sysRole.menus)
  roles: SysRole[];
}
